package org.come.Jpanel;

import java.awt.Color;
import java.awt.Dimension;
import java.math.BigDecimal;

import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingConstants;

import org.come.entity.TeamRole;
import org.come.until.AnalysisString;
import org.come.until.CutButtonImage;

import com.tool.tcpimg.UIUtils;

/**
 * @author HGC<br>
 * @time 2020年4月21日 上午9:41:09<br>
 * @class 类名:TeamArenaModelJPanel 组队展示个人面板<br>
 */
public class TeamArenaModelJPanel extends JPanel {
    
    private JLabel labImg,labName,labLvl;
    private BigDecimal teamRoleId;
    private int tcpType=0;
    public TeamArenaModelJPanel() {
        setPreferredSize(new Dimension(93,110));
        setOpaque(false);
        setLayout(null);
        
        getLabImg();
        getLabLvl();
        getLabName();
    }
    
    public void showRole(TeamRole teamRole){
        if(teamRole== null){
            teamRoleId = null;
            labImg.setIcon(null);
            labName.setText(null);
            labLvl.setText(null);
            tcpType = 0;
            return;
        }
        this.teamRoleId = teamRole.getRoleId();
        ImageIcon image = CutButtonImage.getImage("img/head/s" + teamRole.getSpeciesId() + ".png", -1, -1);
        labImg.setIcon(image);
        labName.setText(teamRole.getName());
        labLvl.setText(AnalysisString.lvl(teamRole.getGrade())+"级");
    }
    
    
    public JLabel getLabImg() {
        if(labImg == null){
            labImg = new JLabel();
            labImg.setBounds(26, 20, 40, 40);
            this.add(labImg);
        }
        return labImg;
    }

    public void setLabImg(JLabel labImg) {
        this.labImg = labImg;
    }

    public JLabel getLabName() {
        if(labName == null){
            labName = new JLabel();
            labName.setBounds(0, 67, 93, 15);
            labName.setFont(UIUtils.TEXT_FONT);
            labName.setHorizontalAlignment(SwingConstants.CENTER);
            this.add(labName);
        }
        return labName;
    }

    public void setLabName(JLabel labName) {
        this.labName = labName;
    }

    public JLabel getLabLvl() {
        if(labLvl == null){
            labLvl = new JLabel();
            labLvl.setBounds(0, 82, 93, 15);
            labLvl.setForeground(Color.red);
            labLvl.setFont(UIUtils.TEXT_FONT);
            labLvl.setHorizontalAlignment(SwingConstants.CENTER);
            this.add(labLvl);
        }
        return labLvl;
    }

    public void setLabLvl(JLabel labLvl) {
        this.labLvl = labLvl;
    }

    public BigDecimal getTeamRoleId() {
        return teamRoleId;
    }

    public void setTeamRoleId(BigDecimal teamRoleId) {
        this.teamRoleId = teamRoleId;
    }

    public int getTcpType() {
        return tcpType;
    }

    public void setTcpType(int tcpType) {
        this.tcpType = tcpType;
    }
    
}
